{% extends "front/front_base.html" %}

{% block title %}
    搜索结果
{% endblock %}

{% block head %}
    <link rel="stylesheet" href="{{ load_static_file("front/css/front_index.css") }}">
{% endblock %}

{% block body %}
    <div class="lg-container">
        <div class="search-result-header">
            <h3>搜索结果： "{{ keyword }}"</h3>
        </div>
        
        <!-- 选项栏 -->
        <div class="search-options">
            <!-- 第一栏：板块选项 -->
            <div class="board-filter-group">
                <ul class="board-filter-list">
                    {% if current_board == -1 %}
                        <li class="active"><a href="{{ url_for("front.query_post", kw=keyword, st=current_sort) }}">所有板块</a></li>
                    {% else %}
                        <li><a href="{{ url_for("front.query_post", kw=keyword, st=current_sort) }}">所有板块</a></li>
                    {% endif %}
                    
                    {% for board in boards %}
                        {% if current_board == board.id %}
                            <li class="active">
                                <a href="{{ url_for("front.query_post", kw=keyword, st=current_sort, bd=board.id) }}">{{ board.name }}</a>
                            </li>
                        {% else %}
                            <li>
                                <a href="{{ url_for("front.query_post", kw=keyword, st=current_sort, bd=board.id) }}">{{ board.name }}</a>
                            </li>
                        {% endif %}
                    {% endfor %}
                </ul>
            </div>
            
            <!-- 第二栏：排序选项 -->
            <div class="sort-filter-group">
                <ul class="sort-filter-list">
                    {% if current_sort == 1 %}
                        <li class="active">
                            <a href="{{ url_for("front.query_post", kw=keyword, st=1, bd=current_board) }}">最新</a>
                        </li>
                    {% else %}
                        <li>
                            <a href="{{ url_for("front.query_post", kw=keyword, st=1, bd=current_board) }}">最新</a>
                        </li>
                    {% endif %}
                    
                    {% if current_sort == 2 %}
                        <li class="active">
                            <a href="{{ url_for("front.query_post", kw=keyword, st=2, bd=current_board) }}">点赞最多</a>
                        </li>
                    {% else %}
                        <li>
                            <a href="{{ url_for("front.query_post", kw=keyword, st=2, bd=current_board) }}">点赞最多</a>
                        </li>
                    {% endif %}
                    
                    {% if current_sort == 3 %}
                        <li class="active">
                            <a href="{{ url_for("front.query_post", kw=keyword, st=3, bd=current_board) }}">评论最多</a>
                        </li>
                    {% else %}
                        <li>
                            <a href="{{ url_for("front.query_post", kw=keyword, st=3, bd=current_board) }}">评论最多</a>
                        </li>
                    {% endif %}
                </ul>
            </div>
        </div>
        
        <!-- 帖子列表 -->
        <div class="post-group">
            <ul class="post-list-group">
                {% for post in posts %}
                    <li>
                        <div class="author-avatar-group">
                            <img src="{{ url_for("media.get_avatar", filename=post.author.avatar) }}" alt="">
                        </div>
                        <div class="post-info-group">
                            <p class="post-title">
                                <a href="{{ url_for("front.post_detail", post_id=post.id) }}"
                                   target="_blank">{{ post.title }}</a>
                                {% if post.highlight %}
                                    <span class="label label-danger">精华帖</span>
                                {% endif %}
                            </p>
                            <p class="post-info">
                                <span>作者:{{ post.author.username }}</span>
                                <span>发表时间:{{ post.create_time }}</span>
                                <span>评论:{{ comment_count[post.id] }}</span>
                                <span>点赞:{{ post.likes_num }}</span>
                            </p>
                        </div>
                    </li>
                {% else %}
                    <li class="no-results">
                        <p>没有找到相关帖子</p>
                    </li>
                {% endfor %}
            </ul>
            
            <!-- 分页 -->
            <div style="text-align:center;">
                {{ pagination.links }}
            </div>
        </div>
    </div>
    
    <div class="sm-container">
        <div style="padding-bottom:10px;">
            <button class="btn btn-warning btn-block">
                <a href="{{ url_for("front.post_public") }}">发布帖子</a>
            </button>
        </div>
    </div>
{% endblock %}
